package SwingView.Assignment;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import JDBC.PeopleActivities;
import JDBC.StudentAssignmentActivities;
import SwingController.CmsPresenter;
import SwingModel.CmsAssignment;
import SwingModel.CmsAssignmentSubmission;
import SwingModel.CmsStudent;
import SwingModel.CmsUser;
import SwingView.CmsMainView;

public class ALAssignmentViewSubmission implements ActionListener{

	private CmsAssignment asgm;

	public ALAssignmentViewSubmission(CmsAssignment asgm){
		this.asgm = asgm;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		CmsUser user = CmsPresenter.user;
		CmsMainView mainView = CmsPresenter.mainView;
		
		List<CmsStudent> students = PeopleActivities.getListOfStudent(user.getSelectedCourse().getCourseID());
		List<CmsAssignmentSubmission> asgmSubs = new ArrayList();
		for(CmsStudent student : students){
			asgmSubs.add(StudentAssignmentActivities.getSubmission(student.getUsername(), asgm.getAsgmID()));
		}
		
		mainView.displayAssignmentSubmissionViewPage(asgm, asgmSubs, students);
	}

}
